﻿Ext.tip.QuickTipManager.init();
Ext.define('MyDesktop.Login', {
    extend: 'Ext.window.Window',
    id: 'login-win',
    init: function () {
        this.launcher = {
            text: 'Login Window',
            iconCls: 'icon-grid',
            handler: this.createWindow,
            scope: this
        };
    },
    createWindow: function () {
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('login-win');
        if (!win) {
            win = desktop.createWindow({
                id: 'login-win',
                title: 'Login Window',
                width: 300,
                height: 150,
                iconCls: 'login-grid',
                constrainHeader: true,
                items: [{
                    xtype: 'textfield',
                    width: 250,
                    height: 20,
                    fieldLabel: '用户名',
                    blankText: '用户名不能为空',
                    name: 'UserName',
                    id: 'UserName',
                    allowBlank: false
                }, {
                    xtype: 'textfield',
                    width: 250,
                    height: 20,
                    fieldLabel: '密   码',
                    allowBlank: false,
                    blankText: '密码不能为空',
                    name: 'PassWord',
                    id: 'PassWord',
                    inputType: 'password'
                }],
                buttons: [{
                    text: '登录',
                    handler: function () {
                        alert($("#UserName"));
                        $.ajax({
                            url: "/Home/Index",
                            dataType: "json",
                            data: { username: $("#UserName").val(), password: $("#PassWord").val() },
                            success: function (data) {
                                alert(data);
                            }
                        })

                    }
                }]
            })
            Ext.apply(this, {
                title: '用户登陆',
                closeAction: 'hide',
                closable: false,
                iconCls: 'win',
                modal: true,
                plain: true,
                resizable: false,
                items: form
            });
            this.callParent(arguments);
        }
        win.show();
        return win;
    }
});
